{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Introduction to Hub Initiatives and Sites"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "In this sample notebook we will demonstrate how to search for initiatives across a Hub, create a new initiative and edit the layout of its site, link and unlink a page to that site, and clone a site. We will also clone the same site to an Enterprise organization to demonstrate cross-platform cloning of Hub Sites. Finally, we will demonstrate how a site can be fetched using its domain. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "from arcgis.gis import GIS"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Login to Hub\n",
    "\n",
    "In the interest of demonstrating the Hub Premium `Initiative`, we will sign into a Hub. Sign-in with your ArcGIS credentials while executing this sample notebook to leverage the capabilities of your Hub/Sites licensing."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter password: ········\n"
     ]
    }
   ],
   "source": [
    "gis = GIS(profile=\"your_online_hub_premium_profile\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "myhub = gis.hub"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Searching for Initiatives\n",
    "\n",
    "You can either search for initiatives or filter using parameters like `title`, `owner`, `tags`."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Initiative title:\"Community Test\" owner:brollison_dcdev>,\n",
       " <Initiative title:\"Increase Community Pride - Graham\" owner:ghudgins5>,\n",
       " <Initiative title:\"Community Driven Conservation\" owner:rohitsharma_dcdev>,\n",
       " <Initiative title:\"Increase Community Pride Hamhands\" owner:phammons_dcdev>,\n",
       " <Initiative title:\"Increase Community Pride - v181203\" owner:ghudgins5>,\n",
       " <Initiative title:\"Community Driven Conservation -Sharma\" owner:rohitsharma_dcdev>,\n",
       " <Initiative title:\"Racial Equity Community Outreach\" owner:jdev_dcdev>,\n",
       " <Initiative title:\"Increase Community Pride\" owner:ghudgins5>,\n",
       " <Initiative title:\"Increase Community Pride - v190318\" owner:ghudgins5>,\n",
       " <Initiative title:\"Community Parks Site\" owner:KThompson_dcdev>,\n",
       " <Initiative title:\"Racial Equity Community Outreach\" owner:mmajumdar_dcdev>,\n",
       " <Initiative title:\"Community User Sign-Up\" owner:brollison_dcdev>,\n",
       " <Initiative title:\"Community User Sign-Up\" owner:brollison_dcdev>,\n",
       " <Initiative title:\"Sharma- Community Driven Conservation\" owner:rohitsharma_dcdev>]"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "myhub.initiatives.search(title='community')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Creating an initiative"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://dcdev.maps.arcgis.com/home/item.html?id=a9034163a7534b1480f1ce834b8336b0' target='_blank'>\n",
       "                        <img src='http://static.arcgis.com/images/desktopapp.png' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://dcdev.maps.arcgis.com/home/item.html?id=a9034163a7534b1480f1ce834b8336b0' target='_blank'><b>A sample Hub Initiative1</b>\n",
       "                        </a>\n",
       "                        <br/>Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.<img src='https://dcdev.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\" width=16 height=16>Hub Initiative by mmajumdar_dcdev\n",
       "                        <br/>Last Modified: July 07, 2023\n",
       "                        <br/>0 comments, 0 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"A sample Hub Initiative1\" type:Hub Initiative owner:mmajumdar_dcdev>"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i1 = myhub.initiatives.add(title='A sample Hub Initiative1')\n",
    "i1.item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A Hub Initiative comes with an Initiative item and a Site item. You also get a Content Team group created to manage the content in your initiative's content library and a Followers Team group that maintains a list of the followers of the initiative. Users with Administrative privileges that create an initiative will also have a Core Team group created as part of the initiative, to allow collaboration among members of that team."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fetching the site for this initiative \n",
    "\n",
    "The site can be fetched using the `site_id` property of the initiative."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Site title:\"A sample Hub Initiative1\" owner:mmajumdar_dcdev>"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1 = myhub.sites.get(i1.site_id)\n",
    "s1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Sites can also be fetched using the item id of the site for Hub Basic and Enterprise Sites."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://dcdev.maps.arcgis.com/home/item.html?id=6c477621242e47259577b19c5cf04c0d' target='_blank'>\n",
       "                        <img src='' width='200' height='133' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://dcdev.maps.arcgis.com/home/item.html?id=6c477621242e47259577b19c5cf04c0d' target='_blank'><b>Urban Analytics Techniques</b>\n",
       "                        </a>\n",
       "                        <br/>Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.<img src='https://dcdev.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\" width=16 height=16>Hub Site Application by mmajumdar_dcdev\n",
       "                        <br/>Last Modified: March 10, 2022\n",
       "                        <br/>0 comments, 28 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"Urban Analytics Techniques\" type:Hub Site Application owner:mmajumdar_dcdev>"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s2 = myhub.sites.get('6c477621242e47259577b19c5cf04c0d')\n",
    "s2.item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Linking a page to this site\n",
    "\n",
    "Linking a page to a site is a two step process. First, you will fetch the page of interest, then you will link it to the site object with a slug for that page."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://dcdev.maps.arcgis.com/home/item.html?id=1c75da020b2f4943a3f657ef59fc1bc8' target='_blank'>\n",
       "                        <img src='' width='200' height='133' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://dcdev.maps.arcgis.com/home/item.html?id=1c75da020b2f4943a3f657ef59fc1bc8' target='_blank'><b>page space</b>\n",
       "                        </a>\n",
       "                        <br/><img src='https://dcdev.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\" width=16 height=16>Hub Page by mmajumdar_dcdev\n",
       "                        <br/>Last Modified: May 30, 2023\n",
       "                        <br/>0 comments, 151 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"page space\" type:Hub Page owner:mmajumdar_dcdev>"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "#Fetching a page\n",
    "new_page = myhub.pages.get('1c75da020b2f4943a3f657ef59fc1bc8')\n",
    "new_page.item"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<Page title:\"page space\" owner:mmajumdar_dcdev>]"
      ]
     },
     "execution_count": 9,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.pages.link(new_page, slug='linked page space')\n",
    "s1.pages.search()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Unlinking a page from this site\n",
    "\n",
    "Unlinking is useful when you have a page that is no longer needed for a site, but you do not wish to delete that page from the other sites it is linked to."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[]"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.pages.unlink(new_page)\n",
    "s1.pages.search()"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Editing the layout of this site\n",
    "\n",
    "To edit a layout of a site, first fetch the layout of that site."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "layout = s1.layout"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'#3276ae'"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "layout.sections[1].style.background.color"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "As we can see, this section has a blue background color.\n",
    "\n",
    "![image](https://user-images.githubusercontent.com/13968196/158464500-fbb3fa83-f091-41ba-b2eb-740a633a2078.png)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We can change it to a deep red by assigning the background color value and calling the `update_layout` method on the site object."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "'#800000'"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "layout.sections[1].style.background.color = '#800000'\n",
    "layout.sections[1].style.background.color"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.update_layout(layout)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The background color is now a dark red.\n",
    "\n",
    "![image](https://user-images.githubusercontent.com/13968196/158464917-76a90219-127b-4a74-ac3e-4c70de62f3e4.png)\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Editing title on the site\n",
    "\n",
    "We can see the title of this site is 'New Initiative'.\n",
    "\n",
    "![image](https://user-images.githubusercontent.com/13968196/158465157-4a16a154-eccd-4050-a33b-1afaed08f5d3.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "To change this, we can fetch the card for this section and update it with the json for the new title 'A Sample Hub Initiative'."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'component': {'name': 'markdown-card', 'settings': {'schemaVersion': 1, 'markdown': '\\n<br>\\n<br>\\n<br>\\n<br>\\n<br><h1 style=\"text-align: center;\">New Initiative</h1><p style=\"text-align: center;\"><br></p><p style=\"text-align: center;\"><br></p><p style=\"text-align: center;\">What will this initiative achieve if successful?</p>\\n\\n\\n<br>\\n<br>\\n<br>\\n<br>\\n<br>'}}, 'width': 12, 'showEditor': False}"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "layout.sections[0].rows[0].cards[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "{'component': {'name': 'markdown-card',\n",
       "  'settings': {'markdown': \" <br> <br> <br> <br> <br><h1 style='text-align: center; '>A sample Hub Initiative</h1><p style='text-align: center; '><br></p><p style='text-align: center; '><br></p><p style='text-align: center; '>What will this initiative achieve if successful?</p> <br> <br> <br> <br> <br>\"}},\n",
       " 'width': 12,\n",
       " 'showEditor': False}"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "layout.sections[0].rows[0].cards[0] = {'component': {'name': 'markdown-card', 'settings': {'markdown': \" <br> <br> <br> <br> <br><h1 style='text-align: center; '>A sample Hub Initiative</h1><p style='text-align: center; '><br></p><p style='text-align: center; '><br></p><p style='text-align: center; '>What will this initiative achieve if successful?</p> <br> <br> <br> <br> <br>\"}}, 'width': 12, 'showEditor': False}\n",
    "layout.sections[0].rows[0].cards[0]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 17,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1.update_layout(layout)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Now the title has successfully been changed.\n",
    "\n",
    "![image](https://user-images.githubusercontent.com/13968196/213138931-409df3e5-019b-4805-a246-4ee00eb67ee7.png)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Fetching sites with site domain\n",
    "\n",
    "Sites can be fetched by their `itemid`. However, in cases where you do not have the `siteid` for a site that you have access to, you can fetch the item using the following command:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://dcdev.maps.arcgis.com/home/item.html?id=aab130d377984b0387a19b7daacb111c' target='_blank'>\n",
       "                        <img src='' width='200' height='133' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://dcdev.maps.arcgis.com/home/item.html?id=aab130d377984b0387a19b7daacb111c' target='_blank'><b>Aloha Challenge</b>\n",
       "                        </a>\n",
       "                        <br/>The Aloha+ Challenge is Hawai‘i's local framework to achieve the SDGs with a Dashboard to track progress, provide accountability and ensure transparency on Hawai‘i's sustainability goals.<img src='https://dcdev.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\" width=16 height=16>Hub Site Application by bbutoaj\n",
       "                        <br/>Last Modified: July 05, 2023\n",
       "                        <br/>0 comments, 452198 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"Aloha Challenge\" type:Hub Site Application owner:bbutoaj>"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "aloha = myhub.sites.get_by_domain('alohachallenge.hawaii.gov')\n",
    "aloha.item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cloning an initiative/site in the same org\n",
    "\n",
    "We clone an initiaitve in the same organization by passing the initiative object to the clone method."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://dcdev.maps.arcgis.com/home/item.html?id=2acae6b0e8e04e908f3e530b499556f6' target='_blank'>\n",
       "                        <img src='http://static.arcgis.com/images/desktopapp.png' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://dcdev.maps.arcgis.com/home/item.html?id=2acae6b0e8e04e908f3e530b499556f6' target='_blank'><b>A sample Hub Initiative1-copy-1688766859085</b>\n",
       "                        </a>\n",
       "                        <br/>Create your own initiative by combining existing applications with a custom site. Use this initiative to form teams around a problem and invite your community to participate.<img src='https://dcdev.maps.arcgis.com/home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\" width=16 height=16>Hub Initiative by mmajumdar_dcdev\n",
       "                        <br/>Last Modified: July 07, 2023\n",
       "                        <br/>0 comments, 0 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"A sample Hub Initiative1-copy-1688766859085\" type:Hub Initiative owner:mmajumdar_dcdev>"
      ]
     },
     "execution_count": 19,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i1_clone = myhub.initiatives.clone(i1)\n",
    "i1_clone.item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Cloning an initiative/site from Hub to Enterprise\n",
    "\n",
    "Cloning an initiative to Enterprise requires signing into that organization and then cloning the site into it. You can clone a site by calling the clone method on the `sites` property of the target `GIS` object and providing a reference to the site object and an optional title. \n",
    "\n",
    "Note: Enterprise Sites are supported via the `sites` submodule of the `GIS`, and not the `apps.hub` submodule. "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 21,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Enter password: ········\n"
     ]
    }
   ],
   "source": [
    "gis_portal = GIS(profile='your_enterprise_profile')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 22,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div class=\"item_container\" style=\"height: auto; overflow: hidden; border: 1px solid #cfcfcf; border-radius: 2px; background: #f6fafa; line-height: 1.21429em; padding: 10px;\">\n",
       "                    <div class=\"item_left\" style=\"width: 210px; float: left;\">\n",
       "                       <a href='https://rpubs22001.ags.esri.com/portal/home//home/item.html?id=7e22db7812204685b96551c79a767fe2' target='_blank'>\n",
       "                        <img src='https://rpubs22001.ags.esri.com/portal/home//portalimages/desktopapp.png' class=\"itemThumbnail\">\n",
       "                       </a>\n",
       "                    </div>\n",
       "\n",
       "                    <div class=\"item_right\"     style=\"float: none; width: auto; overflow: hidden;\">\n",
       "                        <a href='https://rpubs22001.ags.esri.com/portal/home//home/item.html?id=7e22db7812204685b96551c79a767fe2' target='_blank'><b>Cloned Example Enterprise Site</b>\n",
       "                        </a>\n",
       "                        <br/><img src='https://rpubs22001.ags.esri.com/portal/home//home/js/jsapi/esri/css/images/item_type_icons/layers16.png' style=\"vertical-align:middle;\" width=16 height=16>Site Application by creator1\n",
       "                        <br/>Last Modified: July 07, 2023\n",
       "                        <br/>0 comments, 0 views\n",
       "                    </div>\n",
       "                </div>\n",
       "                "
      ],
      "text/plain": [
       "<Item title:\"Cloned Example Enterprise Site\" type:Site Application owner:creator1>"
      ]
     },
     "execution_count": 22,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1_enterprise = gis_portal.sites.clone(s1, title='Cloned Example Enterprise Site')\n",
    "s1_enterprise.item"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Only the site item has been cloned in the new organization as this is an Enterprise organization. The Enterprise Site also comes with a Content Team group that helps you manage the items in your site's Content Library. Users with Administrative privileges that create a site will also have a Core Team group created as part of the site, to allow collaboration among members of that team. The script will automatically determine whether to give you an initiative or a site for your particular Hub."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Deleting initiatives and sites\n",
    "\n",
    "We will delete the initiatives and site created as part of this notebook to demonstrate the process of deletion. Deleting a site or initiative not only deletes the items but also the groups created initially. If a site has a page that is not linked to any other site, deleting the site also deletes the page."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 23,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i1.delete()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 24,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "i1_clone.delete()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "scrolled": false
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 25,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "s1_enterprise.delete()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "esriNotebookRuntime": {
   "notebookRuntimeName": "ArcGIS Notebook Python 3 Standard",
   "notebookRuntimeVersion": "6.0"
  },
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.4"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
